<template>
	<view>
		<!-- #ifdef MP-WEIXIN -->
		<view class="list_box" v-if="shangxian!='是'" @click="bindMsg">
			<view class="box_left">订阅消息</view>
			<view class="jia" >
				<u-icon name="plus" color="#FFFFFF"></u-icon>
			</view>
		</view>
		
		<!-- #endif -->
	
		<view class="list_box" v-if="shangxian!='是'" @click="bindTo('/my/feedback/feedback')">
			<view class="box_left">意见反馈</view>
			<image src="../../static/my/icon_go.png" style="width: 11rpx;height: 20rpx;"></image>
		</view>
		<view class="list_box" @click="bindTo('/my/setting/mimi')">
			<view class="box_left">隐私政策</view>
			<image src="../../static/my/icon_go.png" style="width: 11rpx;height: 20rpx;"></image>
		</view>
		<view class="list_box" @click="bindTo('/my/setting/xieyi')">
			<view class="box_left">用户协议</view>
			<image src="../../static/my/icon_go.png" style="width: 11rpx;height: 20rpx;"></image>
		</view>
		<view class="list_box" @click="bindTo('/my/setting/logOff')">
			<view class="box_left">用户注销</view>
			<image src="../../static/my/icon_go.png" style="width: 11rpx;height: 20rpx;"></image>
		</view>
		<view class="login_btn" @click="bindOut()">退出登录</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				shangxian: '是',
				arr: [],
			}
		},
		onLoad() {
			this.$Request.getT('/app/common/type/268').then(res => { //师傅端订单状态通知 268
			
				if (res.code == 0) {
					if (res.data && res.data.value) {
						this.arr.push(res.data.value)
					}
				}
			})
			this.$Request.getT('/app/common/type/338').then(res => { //师傅新订单通知 338
				if (res.code == 0) {
					if (res.data && res.data.value) {
						this.arr.push(res.data.value)
					}
				}
			})
			
			this.shangxian = uni.getStorageSync('shangxian')
		},
		methods: {
			bindMsg(){
				// #ifdef MP-WEIXIN
				if (uni.getStorageSync('sendMsg')) {
					uni.requestSubscribeMessage({
						tmplIds: this.arr,
						success(re) {
							// console.log(re,'**********')
							var datas = JSON.stringify(re);
							if (datas.indexOf("accept") != -1) {
								console.log(re)
								uni.showToast({
									title:'订阅成功',
									icon:'none'
								})
							}
						},
						fail: (res) => {
							console.log(res)
						}
					})
				}
				// #endif
			},
			bindTo(name) {
				let token = this.$queue.getData("token");
				if (token) {
					uni.navigateTo({
						url: name
					})
				}

			},
			bindOut() {
				uni.showModal({
					title: '退出登录',
					content: '是否退出登录',
					success: function(res) {
						if (res.confirm) {
							uni.clearStorage();
							uni.removeStorageSync("image_url")
							uni.removeStorageSync("userId")
							uni.removeStorageSync("status")
							uni.removeStorageSync("nickName")
							uni.removeStorageSync("token")
							uni.removeStorageSync("mobile")
							// uni.showModal({
							// 	showCancel: false,
							// 	title: '退出登录',
							// 	content: res.msg,
							// });
							uni.navigateBack()
							// uni.navigateBack({
							// 	success: () => {
							// 		let page = getCurrentPages().pop(); //跳转页面成功之后
							// 		if (page) {
							// 			let e = {};
							// 			page.onShow(); //执行上个页面的方法
							// 		};
							// 	}
							// })
							// console.log('用户点击确定');
						} else if (res.cancel) {
							console.log('用户点击取消');
							uni.showToast({
								title: '取消退出登录',
								icon: 'none'
							})
						}
					}
				});
			}
		}
	}
</script>

<style>
	.jia{
		background: #346EF6;
		border-radius:50%;
		width: 55rpx;
		height: 55rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	
	
	page {
		background: #FFFFFF;
	}

	.list_box {
		display: flex;
		align-items: center;
		height: 110rpx;
		margin: 0 30rpx;
	}

	.box_left {
		flex: 1;
		display: flex;
		justify-content: left;
		align-items: center;
	}


	.use_image image {
		width: 60rpx;
		height: 60rpx;
	}

	.login_btn {
		width: 90%;
		margin: 0 auto;
		text-align: center;
		background: #346EF6;
		height: 80rpx;
		border-radius: 16rpx;
		color: #ffffff;
		line-height: 80rpx;
		margin-top: 60rpx;
	}
	

</style>